home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / REFERENC / TPR / SOURCE.EXE / KEYTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1992-08-07  |  858b  |  36 lines

  1. { KEYTEST.PAS }
  2. Program KeyTest;
  3. Uses
  4.   Crt;
  5. Var
  6.  Code : Integer;
  7.  
  8.  
  9. Function GetKey : Integer;
  10. { Pauses for input of a single keystroke from the keyboard and returns
  11.   the ASCII value.  In the case where an Extended keyboard key is pressed,
  12.   GetKey returns the ScanCode + 256.  The Turbo Pascal ReadKey function
  13.   is called to perform the keystroke input.  This routine returns a 0
  14.   when an Extended key has been typed (e.g. left or right arrow) and we
  15.   must read the next byte to determined the Scan code.
  16. }
  17. Var
  18.   Ch : Char;
  19. Begin
  20.   Ch := ReadKey;
  21.   If Ord(Ch) <> 0 Then
  22.     GetKey := Ord(Ch)   { Return normal ASCII value }
  23.   Else
  24.   Begin
  25.     { Read the DOS Extended SCAN code that follows }
  26.     GetKey := Ord(ReadKey) + 256;
  27.   End;
  28. End;{GetKey}
  29.  
  30. Begin
  31. Repeat
  32.   Code := GetKey;
  33.   Writeln(Code);
  34. Until Code = 27;
  35. End.
  36.